<?php

//define("AJAX_PATH",THINK_PATH."Extend/Vendor/Ajax");//指定XAjax路径,用于生成JS代码,此处易错,请根据相对位置来调整  
//define("AJAX_PATH",THINK_PATH."Extend/Vendor");//指定XAjax路径,用于生成JS代码,此处易错,请根据相对位置来调整  
//D:\Program Files\Apache Software Foundation\Apache2.2\htdocs\dwz_thinkphp3\ThinkPHP\Extend
define("AJAX_PATH","/dwz_thinkphp3/ThinkPHP/Extend/Vendor/Ajax");//指定XAjax路径,用于生成JS代码,此处易错,请根据相对位置来调整  
class PageAction extends Action {

    public function index() {

		// ================================
		Vendor('Ajax.xajax_core.xajax','','.inc.php'); //Vendor引入xajax.php核心文件  
        $xajax = new xajax();  //实例化xajax类   
        //Vendor("Ajax.Functions");//此处引入的是ajax的处理函数定义文件  
		$xajax->configure("debug", true);
		$xajax->register(XAJAX_FUNCTION, "test_xajax");

		function test_xajax($sColor)
		{
			$objResponse = new xajaxResponse();
			//$objResponse->assign('div1', 'style.color', $sColor);
			$objResponse->Alert(" dfgdfgdfg dfgdf");
			return $objResponse;
		
			return $objResponse;
		}

       $xajax->processRequest(); //交给xajax处理  
      //  $xajax->configure('javascript URI',"../App/ThinkPHP/Extend/Vendor/Ajax/"); //生成JS代码,此处参数AJAX_PATH是为了引用其中的xajax_JS文件夹 
        $xajax->configure('javascript URI',AJAX_PATH); //生成JS代码,此处参数AJAX_PATH是为了引用其中的xajax_JS文件夹 
	   
		//$this->ajaxinfo = $xajax->printJavascript("../App/ThinkPHP/Extend/Vendor/Ajax/");
		$this->ajaxinfo = $xajax->printJavascript(AJAX_PATH);

        $this->assign('ajaxJS', $this->ajaxinfo );//模板赋值 
		
		// ========================================
		
		
		
		import ( "@.ORG.Util.Page" ); //G:\xampp\htdocs\dwz_thinkphp3\Admin\Lib\ORG\Util      //导入分页类
        //import("ORG.Util.Page");       //导入分页类
        $Form   =   M('Form');
        $count  = $Form->count();    //计算总数
		//创建分页对象
		if (! empty ( $_REQUEST ['listRows'] )) {
			$listRows = $_REQUEST ['listRows'];
		} else {
			$listRows = '';
		}
        $Page = new Page($count,$listRows); //每页5行
        $list   = $Form->limit($Page->firstRow. ',' . $Page->listRows)->order('id desc')->select();

        // 模拟设置分页额外传入的参数
        $Page->parameter    =   'search=key&name=thinkphp'; //定义参数
        // 设置分页显示
        //$Page->setConfig('header', '条数据');
        ///$Page->setConfig('first', '<<');
        //$Page->setConfig('last', '>>');
        $page2 = $Page->show();
        $this->assign("page", $page2);
        $this->assign("list", $list);

		//zhanghuihua@msn.com
		$this->assign ( 'totalCount', $count );
		$this->assign ( 'numPerPage', $Page->listRows );
		$this->assign ( 'currentPage', !empty($_REQUEST[C('VAR_PAGE')])?$_REQUEST[C('VAR_PAGE')]:1);

        $this->display();
    }

}